package znbkTopicType.response;

import android.content.Context;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.example.lancooznbk.R;
import org.apache.commons.lang3.StringEscapeUtils;

import lancooControl.CustomEditText;
import znbkTestPaperCtfd.activity.WrongTopicTutoringPaperActivity;
import znbkTestPaperInfor.ZnbkPaperDef;
import znbkTestPaperNtxl.activity.TrainingDifficultProblemsPaperActivity;
import znbkTestPaperRdqh.activity.WeekAscensionPaperActivity;
import znbkTestPaperXtfx.activity.SystemReviewPaperActivity;

import static znbkTestPaperCtfd.activity.WrongTopicTutoringPaperActivity.mEntityCtfd;
import static znbkTestPaperLstjt.activity.HistoryRecommendQuesPaperActivity.mEntityLstjt;
import static znbkTestPaperNtxl.activity.TrainingDifficultProblemsPaperActivity.mEntityNtxl;
import static znbkTestPaperRdqh.activity.WeekAscensionPaperActivity.mEntityRdqh;
import static znbkTestPaperXtfx.activity.SystemReviewPaperActivity.mEntityXtfx;

/**
 * Created by Administrator on 2018\3\5 0005.
 */

public class ZnbkResponseJdtAdapter extends BaseAdapter

{

    private LayoutInflater mInflater;
    private Context mContext;
    //当前试题数量
    private int SumItem;
    //当前试题在当前试卷的ID
    private int PaperID;
    //当前问题小题所在大题的ID
    private int OptionID;
    private int ModelFrom;//试卷来源

    private int tvBlack;
    private int tvBlue;
    private int tvWhite;
    private int tvGreen;
    private int tvRed;
    private int tvGray;


    private ViewHolder holder = null;
    private class ViewHolder {
        WebView mWvItemContent;//大题文本题干区
        CustomEditText mEdtStuAnswer;//作文输入区
        LinearLayout mLayoutCheckAnalysis;//答案回看解析区
        LinearLayout mLayoutStuAnswer;//我的答案显示区域
        LinearLayout mLayoutAnswer;//参考答案显示区域
        LinearLayout mLayoutStuAssess;//自评显示区域
        LinearLayout mLayoutAnalysis;//解析内容区
        LinearLayout mLayoutTvAnswer;//正确答案文字显示区域
        LinearLayout mLayoutTvStuAnswer;//学生答案文字显示区域
        RadioGroup mRgAssess;
        RadioButton mRBtnExcellent;
        RadioButton mRBtnGood;
        RadioButton mRBtnQualified;
        RadioButton mRBtnRange;
        TextView mTvStuAssess;//自评结果
        TextView mTvAnalysis;//解析
        TextView mTvAnswerAmount;//小题总数

        private ViewHolder(View convertView) {
            mWvItemContent = (WebView) convertView.findViewById(R.id.wv_itemContent);
            mEdtStuAnswer = (CustomEditText) convertView.findViewById(R.id.edt_stuAnswer);
            mLayoutCheckAnalysis = (LinearLayout) convertView.findViewById(R.id.layout_checkAnalysis);
            mLayoutCheckAnalysis = (LinearLayout) convertView.findViewById(R.id.layout_checkAnalysis);
            mLayoutStuAnswer = (LinearLayout) convertView.findViewById(R.id.layout_stuAnswer);
            mLayoutAnswer = (LinearLayout) convertView.findViewById(R.id.layout_answer);
            mLayoutStuAssess = (LinearLayout) convertView.findViewById(R.id.layout_stuAssess);
            mLayoutAnalysis = (LinearLayout) convertView.findViewById(R.id.layout_analysis);
            mLayoutTvAnswer =  (LinearLayout) convertView.findViewById(R.id.layout_tvAnswer);
            mLayoutTvStuAnswer = (LinearLayout) convertView.findViewById(R.id.layout_tvStuAnswer);
            mRgAssess = (RadioGroup) convertView.findViewById(R.id.rg_assess);
            mRBtnExcellent = (RadioButton) convertView.findViewById(R.id.rbtn_excellent);
            mRBtnGood = (RadioButton) convertView.findViewById(R.id.rbtn_good);
            mRBtnQualified = (RadioButton) convertView.findViewById(R.id.rbtn_qualified);
            mRBtnRange = (RadioButton) convertView.findViewById(R.id.rbtn_range);
            mTvStuAssess = (TextView) convertView.findViewById(R.id.tv_stuAssess);
            mTvAnalysis = (TextView) convertView.findViewById(R.id.tv_analysis);
            mTvAnswerAmount = (TextView) convertView.findViewById(R.id.tv_answerAmount);
        }
    }

    /*
   * 获取小题选项信息
   * */
    private int childIndex ;//小题编号
    private String subChildAsk;//题干信息
    private int status;//试卷的作答状态
    private String stuAssess;//自评/机评结果
    private String stuAnswer;//用户答案
    private String answer;//正确答案
    private String analysis;//答案解析
    private int totalItemCount;//小题数量
    public ZnbkResponseJdtAdapter(Context context, int sumItem, int paperID, int optionID, int modelFrom) {
        mInflater = LayoutInflater.from(context);
        this.mContext = context;
        this.SumItem = sumItem;
        this.PaperID = paperID;
        this.OptionID = optionID;
        this.ModelFrom = modelFrom;

        tvBlack = mContext.getResources().getColor(R.color.black);
        tvBlue = mContext.getResources().getColor(R.color.blue);
        tvWhite = mContext.getResources().getColor(R.color.white);
        tvGreen = mContext.getResources().getColor(R.color.green);
        tvRed = mContext.getResources().getColor(R.color.red);
        tvGray = mContext.getResources().getColor(R.color.gray);
    }

    @Override
    public int getCount() {
        return SumItem;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.znbk_adapter_response_jd_item, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        /*
        * 获取作文题用户相关信息
        * */
        getQuesInfor();

        /*
        * 显示题干信息
        * */
        showQuesInfor();

        /*
        * 显示用户回看解析相关信息
        */
        showAnalysis();

        return convertView;
    }


    private String[] smallQueAnswer;
    private String[] smallQuesStuAnswer;
    private String[] smallQuesAssess;
    private int smallQuesAllAmount;
    private double smallQuesScore;
    /*
    * 获取作文题用户相关信息
    * */
    private void  getQuesInfor(){

        if(ModelFrom== ZnbkPaperDef.FROM_TRAINING_DIFFICULT_PROBLEMS) {
            childIndex = mEntityNtxl.getTKQue().getChildList().get(OptionID).getChildIndex();
            subChildAsk = mEntityNtxl.getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildAsk();
            stuAnswer = mEntityNtxl.getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAnswer();
            status = mEntityNtxl.getAnswerState();
            answer = mEntityNtxl.getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildAnswer();
            analysis = mEntityNtxl.getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildAnalyze();
            stuAssess = mEntityNtxl.getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAssess();
            totalItemCount = mEntityNtxl.getTKQue().getTotalItemCount();
        }else if(ModelFrom==ZnbkPaperDef.FROM_SYSTEM_REVIEW) {
            childIndex = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).getChildIndex();
            subChildAsk = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).getSubChildList().get(0).getSubChildAsk();
            stuAnswer = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAnswer();
            status = mEntityXtfx.getModelSinglePaperInfo().getModelPaperInfo().getAnswerState();
            answer = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).getSubChildList().get(0).getSubChildAnswer();
            analysis = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).getSubChildList().get(0).getSubChildAnalyze();
            stuAssess = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAssess();
            totalItemCount = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getTotalItemCount();
        }else if(ModelFrom==ZnbkPaperDef.FROM_WEEK_ASCENSION){
            childIndex = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).getChildIndex();
            subChildAsk = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).getSubChildList().get(0).getSubChildAsk();
            stuAnswer = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAnswer();
            status = mEntityRdqh.getModelSinglePaperInfo().getModelPaperInfo().getAnswerState();
            answer = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).getSubChildList().get(0).getSubChildAnswer();
            analysis = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).getSubChildList().get(0).getSubChildAnalyze();
            stuAssess = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAssess();
            totalItemCount = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getTotalItemCount();
        }else if(ModelFrom==ZnbkPaperDef.FROM_HISTORY_RECOMMEND_QUESTION){
            childIndex = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(OptionID).getChildIndex();
            subChildAsk = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildAsk();
            stuAnswer = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAnswer();
            status = 3;
            answer = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildAnswer();
            analysis = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildAnalyze();
            stuAssess = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAssess();
            totalItemCount = mEntityLstjt.get(PaperID).getTKQue().getTotalItemCount();
        }else if(ModelFrom == ZnbkPaperDef.FROM_WRONG_TOPIC_TUTORING){
            int anotherPaperID = -1;
            if(PaperID==0){
                status = 3;
                childIndex = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(0).getChildIndex();
                subChildAsk = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAsk();
                stuAnswer = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildStuAnswer();
                answer = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnswer();
                analysis = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnalyze();
                stuAssess = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildStuAssess();
                totalItemCount = mEntityCtfd.getPrimitiveQues().getTKQue().getTotalItemCount();
            }else{

                if(PaperID==1){
                    anotherPaperID = PaperID-1;
                    if (mEntityCtfd.getClassicalQues()!= null) {
                        status = 3;
                        childIndex = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(0).getChildIndex();
                        subChildAsk = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAsk();
                        stuAnswer = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildStuAnswer();
                        answer = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnswer();
                        analysis = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnalyze();
                        stuAssess = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildStuAssess();
                        totalItemCount = mEntityCtfd.getClassicalQues().getTKQue().getTotalItemCount();
                    }else{
                        status = mEntityCtfd.getRecQues().get(anotherPaperID).getAnswerState();
                        childIndex = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).getChildIndex();
                        subChildAsk = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildAsk();
                        stuAnswer = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAnswer();
                        answer = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildAnswer();
                        analysis = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildAnalyze();
                        stuAssess = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAssess();
                        totalItemCount = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getTotalItemCount();
                    }
                }else{
                    if (mEntityCtfd.getClassicalQues()!= null) {
                        anotherPaperID = PaperID - 2;
                    } else {
                        anotherPaperID = PaperID - 1;
                    }
                    status = mEntityCtfd.getRecQues().get(anotherPaperID).getAnswerState();
                    childIndex = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).getChildIndex();
                    subChildAsk = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildAsk();
                    stuAnswer = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAnswer();
                    answer = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildAnswer();
                    analysis = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildAnalyze();
                    stuAssess = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAssess();
                    totalItemCount = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getTotalItemCount();
                }
            }
        }
    }

    /*
   * 获取题目题干信息
   * */
    private void showQuesInfor(){

        holder.mTvAnswerAmount.setText("本题包含"+totalItemCount+"个小题");

        holder.mWvItemContent.loadDataWithBaseURL("about:blank", String.valueOf(childIndex)+"、"+subChildAsk, "text/html", "utf-8", null);
        holder.mWvItemContent.getSettings().setDefaultFontSize(18);

        if(status==2||status==3){
            holder.mEdtStuAnswer.setVisibility(View.GONE);
        }else{
            holder.mEdtStuAnswer.setVisibility(View.VISIBLE);
             /*
            * 写入用户作答信息
            * */
            setStuAnswer(stuAnswer);
        }

    }


    /*
    * 用户作答
    * */
    private void setStuAnswer(String stuAnswer){
        if (status==2||status==3) {
            holder.mEdtStuAnswer.setFocusable(false);
            holder.mEdtStuAnswer.setLongClickable(false);
        }else{
            if(stuAnswer.equals("")){
                holder.mEdtStuAnswer.setHint("在此输入答案，提交后请自评");
            }else{
                holder.mEdtStuAnswer.setText(stuAnswer);
            }
            holder.mEdtStuAnswer.setText(stuAnswer);
        }


        holder.mEdtStuAnswer.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                setStuAnswerEdt(s.toString());
            }
        });
    }

    /*
 * 显示试题解析回看信息
 * */
    private void showAnalysis(){

        if(ModelFrom==ZnbkPaperDef.FROM_TRAINING_DIFFICULT_PROBLEMS||
                ModelFrom==ZnbkPaperDef.FROM_SYSTEM_REVIEW||
                ModelFrom==ZnbkPaperDef.FROM_WEEK_ASCENSION||
                ModelFrom==ZnbkPaperDef.FROM_HISTORY_RECOMMEND_QUESTION){

            if (status==2||status==3) {
                /*
                * 显示解析显示区
                * */
                holder.mLayoutCheckAnalysis.setVisibility(View.VISIBLE);

                /*
                * 显示我的答案
                * */
                holder.mLayoutStuAnswer.setVisibility(View.VISIBLE);
                TextView mTvStuAnswer = new TextView(mContext);
                if(stuAnswer.equals("")){
                    mTvStuAnswer.setText(R.string.znbk_no_answered);
                    mTvStuAnswer.setTextColor(tvRed);
                }else {
                    mTvStuAnswer.setText(stuAnswer);
                    if(!stuAnswer.equals(answer)){
                        mTvStuAnswer.setTextColor(tvRed);
                    }else{
                        mTvStuAnswer.setTextColor(tvGreen);
                    }
                }
                holder.mLayoutStuAnswer.addView(mTvStuAnswer);

                /*
                * 显示参考答案
                * */
                holder.mLayoutAnswer.setVisibility(View.VISIBLE);
                TextView mTvAnswer = new TextView(mContext);
                mTvAnswer.setText(Html.fromHtml(answer));
                mTvAnswer.setTextColor(tvGreen);
                holder.mLayoutAnswer.addView(mTvAnswer);

                //显示自评区域
                holder.mLayoutStuAssess.setVisibility(View.VISIBLE);
                if(status==2){
                    /*
                    * 显示自评选项
                    * 隐藏自评结果
                    * */
                    holder.mRgAssess.setVisibility(View.VISIBLE);
                    holder.mRBtnExcellent.setChecked(false);
                    holder.mRBtnGood.setChecked(false);
                    holder.mRBtnQualified.setChecked(false);
                    holder.mRBtnRange.setChecked(false);
                    if(stuAssess.equals("优秀")){
                        holder.mRBtnExcellent.setChecked(true);
                    }else  if(stuAssess.equals("良好")){
                        holder.mRBtnGood.setChecked(true);
                    }else  if(stuAssess.equals("合格")){
                        holder.mRBtnQualified.setChecked(true);
                    }else  if(stuAssess.equals("较差")){
                        holder.mRBtnRange.setChecked(true);
                    }
                    holder.mRgAssess.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                        @Override
                        public void onCheckedChanged(RadioGroup group, int checkedId) {
                            if(checkedId==holder.mRBtnExcellent.getId()){
                                stuAssess = "优秀";
                            }else if(checkedId==holder.mRBtnGood.getId()){
                                stuAssess = "良好";
                            }else if(checkedId==holder.mRBtnQualified.getId()){
                                stuAssess = "合格";
                            }else if(checkedId==holder.mRBtnRange.getId()){
                                stuAssess = "较差";
                            }
                            mEntityNtxl.getTKQue().getChildList().get(0).getSubChildList().get(0).setSubChildStuAssess(stuAssess);
                        }
                    });
                    holder.mTvStuAssess.setVisibility(View.GONE);
                }else if(status==3){
                    /*
                    * 隐藏自评选项
                    * 显示自评结果
                    * */
                    holder.mRgAssess.setVisibility(View.GONE);
                    holder.mTvStuAssess.setVisibility(View.VISIBLE);

                    if(!stuAssess.equals("")) {
                        holder.mTvStuAssess.setText(stuAssess);
                    }else{
                        holder.mTvStuAssess.setText(R.string.znbk_no_assessed);
                    }

                }

                /*
                * 显示自评内容
                * */
                if(analysis.equals("")){
                    holder.mTvAnalysis.setText(R.string.znbk_no_analysis);
                }else{
                    holder.mTvAnalysis.setText(analysis);
                }
                holder.mTvAnalysis.setTextColor(tvBlack);


            }else{
                holder.mLayoutCheckAnalysis.setVisibility(View.GONE);
            }

        }else if(ModelFrom==ZnbkPaperDef.FROM_WRONG_TOPIC_TUTORING){
            if (PaperID == 0) {

//                //隐藏作答区域
//                holder.mLayoutEdtStuAnswer.setVisibility(View.GONE);
                //显示题目回看解析内容
                holder.mLayoutCheckAnalysis.setVisibility(View.VISIBLE);

               /*
                * 显示我的答案
                * */
                holder.mLayoutStuAnswer.setVisibility(View.VISIBLE);
                TextView mTvStuAnswer = new TextView(mContext);
                if(stuAnswer.equals("")){
                    mTvStuAnswer.setText(R.string.znbk_no_answered);
                    mTvStuAnswer.setTextColor(tvRed);
                }else {
                    mTvStuAnswer.setText(stuAnswer);
                    if(!stuAnswer.equals(answer)){
                        mTvStuAnswer.setTextColor(tvRed);
                    }else{
                        mTvStuAnswer.setTextColor(tvGreen);
                    }
                }
                holder.mLayoutStuAnswer.addView(mTvStuAnswer);

                /*
                * 显示参考答案
                * */
                holder.mLayoutAnswer.setVisibility(View.VISIBLE);
                TextView mTvAnswer = new TextView(mContext);
                mTvAnswer.setText(Html.fromHtml(answer));
                mTvAnswer.setTextColor(tvGreen);
                holder.mLayoutAnswer.addView(mTvAnswer);


                 /*
                * 显示自评区域
                *
                * 隐藏自评选项
                * 显示自评结果
                * */
                holder.mLayoutStuAssess.setVisibility(View.VISIBLE);

                holder.mRgAssess.setVisibility(View.GONE);
                holder.mTvStuAssess.setVisibility(View.VISIBLE);
                if(!stuAssess.equals("")) {
                    holder.mTvStuAssess.setText(stuAssess);
                }else{
                    holder.mTvStuAssess.setText(R.string.znbk_no_assessed);
                }


                //答案解析
                if (!analysis.equals("")) {
                    holder.mTvAnalysis.setText(Html.fromHtml(analysis));
                } else {
                    holder.mTvAnalysis.setText(R.string.znbk_no_analysis);
                }
                holder.mTvAnalysis.setTextColor(tvBlack);

            } else if (PaperID == 1) {

                if (mEntityCtfd.getClassicalQues() != null) {
//                    //隐藏作答区域
//                    holder.mLayoutEdtStuAnswer.setVisibility(View.GONE);
                    //显示题目回看解析内容
                    holder.mLayoutCheckAnalysis.setVisibility(View.VISIBLE);

                    /*
                    * 隐藏我的答案
                    * */
                    holder.mLayoutStuAnswer.setVisibility(View.GONE);

                     /*
                    * 显示参考答案
                    * */
                    holder.mLayoutAnswer.setVisibility(View.VISIBLE);
                    TextView mTvAnswer = new TextView(mContext);
                    mTvAnswer.setText(Html.fromHtml(answer));
                    mTvAnswer.setTextColor(tvGreen);
                    holder.mLayoutAnswer.addView(mTvAnswer);

                    //隐藏自评结果
                    holder.mLayoutStuAssess.setVisibility(View.GONE);

                    //显示答案解析
                    if (!analysis.equals("")) {
                        holder.mTvAnalysis.setText(Html.fromHtml(analysis));
                    } else {
                        holder.mTvAnalysis.setText(R.string.znbk_no_analysis);
                    }

                } else {
                    if (status == 2 || status == 3) {

                        //显示题目回看解析内容
                        holder.mLayoutCheckAnalysis.setVisibility(View.VISIBLE);

                         /*
                        * 显示我的答案
                        * */
                        holder.mLayoutStuAnswer.setVisibility(View.VISIBLE);
                        TextView mTvStuAnswer = new TextView(mContext);
                        if(stuAnswer.equals("")){
                            mTvStuAnswer.setText(R.string.znbk_no_answered);
                            mTvStuAnswer.setTextColor(tvRed);
                        }else {
                            mTvStuAnswer.setText(stuAnswer);
                            if(!stuAnswer.equals(answer)){
                                mTvStuAnswer.setTextColor(tvRed);
                            }else{
                                mTvStuAnswer.setTextColor(tvGreen);
                            }
                        }
                        holder.mLayoutStuAnswer.addView(mTvStuAnswer);

                        /*
                        * 显示参考答案
                        * */
                        holder.mLayoutAnswer.setVisibility(View.VISIBLE);
                        TextView mTvAnswer = new TextView(mContext);
                        mTvAnswer.setText(Html.fromHtml(answer));
                        mTvAnswer.setTextColor(tvGreen);
                        holder.mLayoutAnswer.addView(mTvAnswer);

                        //显示自评区域
                        holder.mLayoutStuAssess.setVisibility(View.VISIBLE);
                        if(status==2){
                    /*
                    * 显示自评选项
                    * 隐藏自评结果
                    * */
                            holder.mRgAssess.setVisibility(View.VISIBLE);
                            holder.mRBtnExcellent.setChecked(false);
                            holder.mRBtnGood.setChecked(false);
                            holder.mRBtnQualified.setChecked(false);
                            holder.mRBtnRange.setChecked(false);
                            if(stuAssess.equals("优秀")){
                                holder.mRBtnExcellent.setChecked(true);
                            }else  if(stuAssess.equals("良好")){
                                holder.mRBtnGood.setChecked(true);
                            }else  if(stuAssess.equals("合格")){
                                holder.mRBtnQualified.setChecked(true);
                            }else  if(stuAssess.equals("较差")){
                                holder.mRBtnRange.setChecked(true);
                            }
                            holder.mRgAssess.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                                @Override
                                public void onCheckedChanged(RadioGroup group, int checkedId) {
                                    if(checkedId==holder.mRBtnExcellent.getId()){
                                        stuAssess = "优秀";
                                    }else if(checkedId==holder.mRBtnGood.getId()){
                                        stuAssess = "良好";
                                    }else if(checkedId==holder.mRBtnQualified.getId()){
                                        stuAssess = "合格";
                                    }else if(checkedId==holder.mRBtnRange.getId()){
                                        stuAssess = "较差";
                                    }
                                    mEntityCtfd.getRecQues().get(0).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).setSubChildStuAssess(stuAssess);
                                }
                            });
                            holder.mTvStuAssess.setVisibility(View.GONE);
                        }else if(status==3){
                    /*
                    * 隐藏自评选项
                    * 显示自评结果
                    * */
                            holder.mRgAssess.setVisibility(View.GONE);
                            holder.mTvStuAssess.setVisibility(View.VISIBLE);

                            if(!stuAssess.equals("")) {
                                holder.mTvStuAssess.setText(stuAssess);
                            }else{
                                holder.mTvStuAssess.setText(R.string.znbk_no_assessed);
                            }

                        }

                        //答案解析
                        if(status==2){
                            holder.mLayoutAnalysis.setVisibility(View.GONE);
                        }else if(status==3){
                            holder.mLayoutAnalysis.setVisibility(View.VISIBLE);
                            if (!analysis.equals("")) {
                                holder.mTvAnalysis.setText(Html.fromHtml(analysis));
                            } else {
                                holder.mTvAnalysis.setText(R.string.znbk_no_analysis);
                            }
                            holder.mTvAnalysis.setTextColor(tvBlack);
                        }

                    } else {
//                        //显示作答区域
//                        holder.mLayoutEdtStuAnswer.setVisibility(View.VISIBLE);
                        /*
                        * 显示输入框我的答案
                        * */
//                        holder.mEdtStuAnswer.setText(stuAnswer);

                        //关闭题目回看解析内容
                        holder.mLayoutCheckAnalysis.setVisibility(View.GONE);
                    }
                }
            } else {
                int anotherPaperID = -1;
                if(mEntityCtfd.getClassicalQues()!=null){
                    anotherPaperID = PaperID-2;
                }else{
                    anotherPaperID = PaperID-1;
                }
                if (status == 2 || status == 3) {
//                    //隐藏作答区域
//                    holder.mLayoutEdtStuAnswer.setVisibility(View.GONE);
                    //显示题目回看解析内容
                    holder.mLayoutCheckAnalysis.setVisibility(View.VISIBLE);

                     /*
                        * 显示我的答案
                        * */
                    holder.mLayoutStuAnswer.setVisibility(View.VISIBLE);
                    TextView mTvStuAnswer = new TextView(mContext);
                    if(stuAnswer.equals("")){
                        mTvStuAnswer.setText(R.string.znbk_no_answered);
                        mTvStuAnswer.setTextColor(tvRed);
                    }else {
                        mTvStuAnswer.setText(stuAnswer);
                        if(!stuAnswer.equals(answer)){
                            mTvStuAnswer.setTextColor(tvRed);
                        }else{
                            mTvStuAnswer.setTextColor(tvGreen);
                        }
                    }
                    holder.mLayoutStuAnswer.addView(mTvStuAnswer);

                        /*
                        * 显示参考答案
                        * */
                    holder.mLayoutAnswer.setVisibility(View.VISIBLE);
                    TextView mTvAnswer = new TextView(mContext);
                    mTvAnswer.setText(Html.fromHtml(answer));
                    mTvAnswer.setTextColor(tvGreen);
                    holder.mLayoutAnswer.addView(mTvAnswer);

                    //显示自评区域
                    holder.mLayoutStuAssess.setVisibility(View.VISIBLE);
                    if(status==2){
                    /*
                    * 显示自评选项
                    * 隐藏自评结果
                    * */
                        holder.mRgAssess.setVisibility(View.VISIBLE);
                        holder.mRBtnExcellent.setChecked(false);
                        holder.mRBtnGood.setChecked(false);
                        holder.mRBtnQualified.setChecked(false);
                        holder.mRBtnRange.setChecked(false);
                        if(stuAssess.equals("优秀")){
                            holder.mRBtnExcellent.setChecked(true);
                        }else  if(stuAssess.equals("良好")){
                            holder.mRBtnGood.setChecked(true);
                        }else  if(stuAssess.equals("合格")){
                            holder.mRBtnQualified.setChecked(true);
                        }else  if(stuAssess.equals("较差")){
                            holder.mRBtnRange.setChecked(true);
                        }
                        final int finalAnotherPaperID = anotherPaperID;
                        holder.mRgAssess.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(RadioGroup group, int checkedId) {
                                if(checkedId==holder.mRBtnExcellent.getId()){
                                    stuAssess = "优秀";
                                }else if(checkedId==holder.mRBtnGood.getId()){
                                    stuAssess = "良好";
                                }else if(checkedId==holder.mRBtnQualified.getId()){
                                    stuAssess = "合格";
                                }else if(checkedId==holder.mRBtnRange.getId()){
                                    stuAssess = "较差";
                                }
                                mEntityCtfd.getRecQues().get(finalAnotherPaperID).getTKQue().getChildList().get(OptionID).getSubChildList().get(0).setSubChildStuAssess(stuAssess);
                            }
                        });
                        holder.mTvStuAssess.setVisibility(View.GONE);
                    }else if(status==3){
                    /*
                    * 隐藏自评选项
                    * 显示自评结果
                    * */
                        holder.mRgAssess.setVisibility(View.GONE);
                        holder.mTvStuAssess.setVisibility(View.VISIBLE);

                        if(!stuAssess.equals("")) {
                            holder.mTvStuAssess.setText(stuAssess);
                        }else{
                            holder.mTvStuAssess.setText(R.string.znbk_no_assessed);
                        }

                    }

                    //答案解析
                    if(status==2){
                        holder.mLayoutAnalysis.setVisibility(View.GONE);
                    }else if(status==3){
                        holder.mLayoutAnalysis.setVisibility(View.VISIBLE);
                        if (!analysis.equals("")) {
                            holder.mTvAnalysis.setText(Html.fromHtml(analysis));
                        } else {
                            holder.mTvAnalysis.setText(R.string.znbk_no_analysis);
                        }
                        holder.mTvAnalysis.setTextColor(tvBlack);
                    }
                } else {
                    //关闭题目回看解析内容
                    holder.mLayoutCheckAnalysis.setVisibility(View.GONE);
                }
            }
        }
    }

    /*
    * 写入作答信息
    * */
    private void setStuAnswerEdt(String strStuAnswer){

        if(ModelFrom==ZnbkPaperDef.FROM_TRAINING_DIFFICULT_PROBLEMS){
            mEntityNtxl.getTKQue().getChildList().get(OptionID).getSubChildList().get(0).setSubChildStuAnswer(strStuAnswer);
            for(int i=0;i<totalItemCount;i++){
                String StuAnswer = mEntityNtxl.getTKQue().getChildList().get(i).getSubChildList().get(0).getSubChildStuAnswer();
                if(!StuAnswer.equals("")){
                    mEntityCtfd.setAnswerState(1);
                    TrainingDifficultProblemsPaperActivity.mSbtnSubmit.setTextColor(tvWhite);
                    break;
                }else{
                    mEntityCtfd.setAnswerState(0);
                    TrainingDifficultProblemsPaperActivity.mSbtnSubmit.setTextColor(tvGray);
                }
            }
        }else if(ModelFrom==ZnbkPaperDef.FROM_SYSTEM_REVIEW){
            mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).
                    getSubChildList().get(0).setSubChildStuAnswer(strStuAnswer);
            for(int i=0;i<totalItemCount;i++){
                String StuAnswer = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).
                        getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAnswer();
                if(!StuAnswer.equals("")){
                    mEntityXtfx.getModelSinglePaperInfo().getModelPaperInfo().setAnswerState(1);
                    SystemReviewPaperActivity.mSbtnSubmit.setTextColor(tvWhite);
                    break;
                }else{
                    mEntityXtfx.getModelSinglePaperInfo().getModelPaperInfo().setAnswerState(0);
                    SystemReviewPaperActivity.mSbtnSubmit.setTextColor(tvGray);
                }
            }
        }else if(ModelFrom==ZnbkPaperDef.FROM_WEEK_ASCENSION){
            mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(OptionID).
                    getSubChildList().get(0).setSubChildStuAnswer(strStuAnswer);
            for(int i=0;i<totalItemCount;i++){
                String StuAnswer = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).
                        getChildList().get(OptionID).getSubChildList().get(0).getSubChildStuAnswer();
                if(!StuAnswer.equals("")){
                    mEntityRdqh.getModelSinglePaperInfo().getModelPaperInfo().setAnswerState(1);
                    WeekAscensionPaperActivity.mSbtnSubmit.setTextColor(tvWhite);
                    break;
                }else{
                    mEntityRdqh.getModelSinglePaperInfo().getModelPaperInfo().setAnswerState(0);
                    WeekAscensionPaperActivity.mSbtnSubmit.setTextColor(tvGray);
                }
            }
        }else if(ModelFrom== ZnbkPaperDef.FROM_WRONG_TOPIC_TUTORING){
            int anotherPaperID = -1;
            if(mEntityCtfd.getClassicalQues()!=null){
                anotherPaperID=PaperID-2;
            }else{
                anotherPaperID=PaperID-1;
            }
            mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(OptionID).
                    getSubChildList().get(0).setSubChildStuAnswer(strStuAnswer);
            for(int i=0;i<totalItemCount;i++){
                String StuAnswer = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(i).
                       getSubChildList().get(0).getSubChildStuAnswer();
                String UpLoadPath = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(i).
                        getSubChildList().get(0).getUpLoadPath();
                if(!StuAnswer.equals("")||!UpLoadPath.equals("")){
                    mEntityCtfd.getRecQues().get(anotherPaperID).setAnswerState(1);
                    WrongTopicTutoringPaperActivity.mSbtnSubmit.setTextColor(tvWhite);
                    break;
                }else{
                    mEntityCtfd.getRecQues().get(anotherPaperID).setAnswerState(0);
                    WrongTopicTutoringPaperActivity.mSbtnSubmit.setTextColor(tvGray);
                }
            }
        }
    }
}